package connection;


import java.util.*;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import connection.ConnectionOracleOR;
import java.sql.*;


//Precisa ser generica
public class QueryOracleOR {

	public QueryOracleOR(){
		
	}
	
	public ArrayList<Object> query( String query ) throws Exception{
        
		ArrayList<Object> result =	new ArrayList<Object>();
		
		try{
			
			ConnectionOracleOR oracleBruno 	= 	new ConnectionOracleOR( );
			Connection conexao 				= 	oracleBruno.newConnection( );			
			Statement statement 			= 	conexao.createStatement();
	        ResultSet rs 					= 	null;	        
	        
            
	        rs = statement.executeQuery( query );
	        
	        while(rs.next())
	        {
	   	
	        	//ArrayList<Object> alRowData = new ArrayList<Object>();
	        	List<Object> alRowData = new ArrayList<Object>();
	        	
	            ResultSetMetaData rsmd 		= rs.getMetaData();
	            int numberOfColumns 		= rsmd.getColumnCount();
	            
	            for(int columnIndex = 1; columnIndex <= numberOfColumns; columnIndex ++){
	                 alRowData.add(rs.getObject(columnIndex));
	            }
	            
	            
	            result.add( alRowData );
	            
	        }
	        
	        
	        
	        rs.close();
	        statement.close();
	        
	        //if (resultSet.next())
	        	//result = resultSet.getString("VNOME");
                
                
		}catch( Exception e){
			
			throw new Exception("erro: "+e.getMessage());
		}

       return result;
	}
	
	
	
}


 


